/**
 * @文件名称: PublishTask.java
 * @类路径:   com.dssrz.weibo4j.task
 * @描述:     TODO
 * @作者:     robin
 * @时间:     2012-3-12 下午05:01:12
 * @版本:     1.0.0
 */
package com.dssrz.weibo4j.task;

import org.apache.log4j.Logger;

import com.dssrz.weibo4j.Timeline;
import com.dssrz.weibo4j.Weibo;
import com.dssrz.weibo4j.model.Status;
import com.dssrz.weibo4j.model.WeiboException;

/**
 * @类功能说明: 定时任务
 * @类修改者:
 * @修改日期:
 * @修改说明:
 * @作者: robin
 * @创建时间: 2012-3-12 下午05:01:12
 * @版本: 1.0.0
 */

public class PublishTask extends Task {

	private static final Logger log = Logger.getLogger(PublishTask.class);

	private String runTime;
	private String access_token;
	private String status;

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.util.TimerTask#run()
	 */
	/**
	 * @return doTime
	 */
	public String getRunTime() {
		return runTime;
	}

	/**
	 * @param doTime
	 *            doTime
	 */
	public void setRunTime(String runTime) {
		this.runTime = runTime;
	}

	/**
	 * @return access_token
	 */
	public String getAccess_token() {
		return access_token;
	}

	/**
	 * @param accessToken
	 *            access_token
	 */
	public void setAccess_token(String accessToken) {
		access_token = accessToken;
	}

	/**
	 * @return status
	 */
	public String getStatus() {
		return status;
	}

	/**
	 * @param status
	 *            status
	 */
	public void setStatus(String status) {
		this.status = status;
	}

	public PublishTask(String runTime) {
		this.runTime = runTime;
	}

	public PublishTask(String runTime, String access_token, String status) {
		this.runTime = runTime;
		this.access_token = access_token;
		this.status = status;
	}

	@Override
	public void run() {
		log.info("定时任务启动!定时时间:" + runTime);
		Weibo weibo = new Weibo();
		weibo.setToken(access_token);
		Timeline tm = new Timeline();
		try {
			Status sta = tm.UpdateStatus(status);
			log.info(sta.toString());
		} catch (WeiboException e) {
			e.printStackTrace();
		}
		log.info("定时任务完成!");
	}

	/* (non-Javadoc)
	 * @see com.dssrz.weibo4j.task.Task#info()
	 */
	@Override
	public String info() {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see com.dssrz.weibo4j.task.Task#needExecuteImmediate()
	 */
	@Override
	protected boolean needExecuteImmediate() {
		// TODO Auto-generated method stub
		return false;
	}

	/* (non-Javadoc)
	 * @see com.dssrz.weibo4j.task.Task#taskCore()
	 */
	@Override
	public Task[] taskCore() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see com.dssrz.weibo4j.task.Task#useDb()
	 */
	@Override
	protected boolean useDb() {
		// TODO Auto-generated method stub
		return false;
	}

}
